package com.baijing.springbootstartermonitor.utils;

import com.baijing.springbootstartermonitor.service.StatusService;
import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * 自定义端点,监控,暂时没实现。
 */
//@Component
//@ConfigurationProperties(prefix = "endpoint.status", ignoreUnknownFields = false)
public class StatusEndPoint extends AbstractEndpoint<String> implements ApplicationContextAware {
    ApplicationContext context;

    public StatusEndPoint() {
        super("status");
    }


    @Override
    public String invoke() {
        StatusService statusService = context.getBean(StatusService.class);
        return "the current status is : " + statusService.getStatus();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.context = applicationContext;
    }
}
